//
//  LaunchDyy.m
//  JFTwxsd
//
//  Created by Peter on 2019/3/14.
//  Copyright © 2019 junfeiweiyejiaoyujituan. All rights reserved.
//

#import "LaunchDyy.h"

@interface LaunchDyy () {
    UIImageView *imgV;
    NSTimer *timer;
}

@end

@implementation LaunchDyy

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self configContents];
    }
    return self;
}

- (void)configContents {
    CGFloat time = 3.0;
    timer = [NSTimer scheduledTimerWithTimeInterval:time target:self selector:self.selector userInfo:nil repeats:NO];
    
    imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"launch1"]];
    imgV.tag = 99008;
    imgV.frame = self.frame;
    imgV.contentMode = UIViewContentModeCenter;
    NSMutableArray *ary = [[NSMutableArray alloc] init];
    for (int i = 1; i < 14; i++) {
        UIImage *m = [UIImage imageNamed:[ NSString stringWithFormat:@"launch%d",i]];
        [ary addObject:m];
    }
    imgV.animationImages = ary;
    //完成一次动画需要的时间
    imgV.animationDuration = time;
    //设置重复次数
    imgV.animationRepeatCount = 0;
    [imgV startAnimating];
    [self addSubview:imgV];
}

- (void)show {
    [self addSubview:imgV];
    [imgV startAnimating];
}

- (void)hide {
    [timer invalidate];
    [self removeFromSuperview];
}

@end
